part of '../repository.dart';

const _kA1CefrLevelValue = 'a1';
const _kA2CefrLevelValue = 'a2';
const _kB1CefrLevelValue = 'b1';
const _kB2CefrLevelValue = 'b2';
const _kC1CefrLevelValue = 'c1';
const _kC2CefrLevelValue = 'c2';

class _CefrLevelDto extends Equatable {
  const _CefrLevelDto._internal({
    required this.cefrLevelString,
  });

  final String cefrLevelString;

  @override
  List<Object?> get props {
    return [
      cefrLevelString,
    ];
  }

  factory _CefrLevelDto.fromString(String cefrLevelString) {
    return _CefrLevelDto._internal(
      cefrLevelString: cefrLevelString,
    );
  }

  factory _CefrLevelDto.fromEntity(CefrLevel cefrLevel) {
    final cefrLevelString = switch (cefrLevel) {
      CefrLevel.a1 => _kA1CefrLevelValue,
      CefrLevel.a2 => _kA2CefrLevelValue,
      CefrLevel.b1 => _kB1CefrLevelValue,
      CefrLevel.b2 => _kB2CefrLevelValue,
      CefrLevel.c1 => _kC1CefrLevelValue,
      CefrLevel.c2 => _kC2CefrLevelValue,
    };

    return _CefrLevelDto._internal(
      cefrLevelString: cefrLevelString,
    );
  }

  @override
  String toString() {
    return cefrLevelString;
  }

  CefrLevel toEntity() {
    return switch (cefrLevelString) {
      _kA1CefrLevelValue => CefrLevel.a1,
      _kA2CefrLevelValue => CefrLevel.a2,
      _kB1CefrLevelValue => CefrLevel.b1,
      _kB2CefrLevelValue => CefrLevel.b2,
      _kC1CefrLevelValue => CefrLevel.c1,
      _kC2CefrLevelValue => CefrLevel.c2,
      _ => throw UnimplementedError(),
    };
  }
}
